package com.guomao.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guomao.entity.Order;
import com.guomao.entity.User;
import com.guomao.mapper.OrderMapper;
import com.guomao.service.OrderService;
import com.guomao.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {

    //从ioc容器中装配userService对象
    @Autowired
    private UserService userService;

    public Order findById(Long id) {
        //1 调用继承过来的getById方法查询订单
        Order order = getById(id);
        //2 调用userService查询订单的用户信息
        User user = userService.getById(order.getUserId());
        order.setUser(user);
        return order;
    }
}